<?php 

ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 

function CompareNameASC($a, $b){
	if ($a[1] == $b[1]) {
		return 0;
	}
	return ($a[1] < $b[1]) ? -1 : 1;;
}

function CompareNameDESC($a, $b){
	if ($a[1] == $b[1]) {
		return 0;
	}
	return ($a[1] > $b[1]) ? -1 : 1;;
}

if(isset($_SESSION['myCarmera']) and is_array($_SESSION['myCarmera'])){
		$winH = 200;
		if(isset($_REQUEST['winH'])) $winH = $_REQUEST['winH'];
		$myCarmera = $_SESSION['myCarmera'];
		if ($_REQUEST['flag']=='0') {
			usort($myCarmera, 'CompareNameASC');
		}else{
			usort($myCarmera, 'CompareNameDESC');
		}
		$index=0;
		foreach ($myCarmera as $key =>$row){
			$index++;
		 ?>
		 <tr onclick="selectcamera(this,'chon<?=$index?>')">
		 	<td width="10%" align="center">
		 	<input  type="checkbox" onclick="selectcamera(this,'chon<?=$index?>')" id="chon<?=$index?>" name="checkCamera[<?=$row[0]?>]" class="checkCamera"/><input class="valueCamera" type="hidden" value="<?=$row[0]?>"/></td>
		 	<td class="last"><?=$row[1]?></td>
		 </tr> 
		 <?php  
		}
		if ($index>0 and $index<$winH/28) {
		 	foreach(range(0,$winH/28-$index) as $i){
		 		?>
		 		<tr>
			 	<td width="10%">&nbsp;</td>
			 	<td class="last">&nbsp;</td>
			 	</tr>
		 	<?php }
		}
	$_SESSION['myCarmera'] = $myCarmera;
	
}

?>

